<?php
	// check if both latest threads are from the same thread
		$threadIds[0] = ($latest_threads[0]['Thread']['thread_id'] == "0") ? $latest_threads[0]['Thread']['id'] : $latest_threads[0]['Thread']['thread_id'];
		$threadIds[1] = ($latest_threads[1]['Thread']['thread_id'] == "0") ? $latest_threads[1]['Thread']['id'] : $latest_threads[1]['Thread']['thread_id'];
		$first = 1;
?>
<div class="headertitle">
	<span class="header">Users</span>
	<span class="header">Profile</span>
	<span class="header">Chris</span>
</div>

<?php echo $this->element('latest_home_threads'); ?>

<div class="homeLeft profileLeft" style="width: 278px; float: left; margin-right: 10px; padding-bottom: 20px">
	<div class="threadLeft">
		<div class="homeTitle"><?php echo $userData['User']['username']; ?></div>
		<div class="display_picturethread">
			<?php echo $this->Html->image('/attachments/avatars/large/' . $userData['User']['user_file_path']); ?>
		</div>
	</div>
	<div style="margin-top: 20px">
		Access: <?php echo $roles[$userData['User']['role']]; ?><br />
		Total Posts: <?php echo $userData['User']['thread_count']; ?><br />
		Joined: <?php echo substr($userData['User']['created'], 0, 10); ?><br /><br />

		<div>
			<div style="margin-left: 10px; float: right"><?php echo $this->Html->image('email2.png'); ?></div>
			<?php echo $this->Html->link('Send a message', array('controller' => 'messages', 'action' => 'send', 'user_id' => 0, 'username' => $userData['User']['username'])); ?>
		</div>

	</div>
</div>
<div class="homeLeft" style="width: 278px; float: left">
	<div class="homeTitle">Last Posts</div>
	<p>
		<?php foreach($latestUserThreads as $thread): ?>
		<?php
			if($threadIds[0] == $threadIds[1]){
				$subtract = ($first === 1) ? 1 : -1;
			}else{
				$subtract = 0;
			}
		?>
		<?php
		echo $this->Html->link(
			trim($thread['title']),
			array(
				'controller' => 'threads',
				'action' => 'view',
				'id' => ($thread['thread_id'] == 0) ? $thread['id'] : $thread['thread_id'],
				'slug' => Inflector::slug($thread['title'], '-'),
				'page' => 1,
				'#' => $thread['id']
			)
		);
		echo " ";
		echo $userData['User']['username'];
		?>
		<br />
		<?php endforeach; ?>
	</p>
</div>
<div style="clear: both"></div>